package work.jame.blog.pojo;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import work.jame.blog.framework.VerificationGroup;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author Jame
 * @since 2023-05-17
 */
@TableName("article")
public class Article implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @Null(message = "非法传入参数", groups = VerificationGroup.Save.class)
    private Long id;

    /**
     * 发布这篇文章的用户id
     */
    @TableField("user_id")
    @Null(message = "非法传入参数",
            groups = {VerificationGroup.Save.class,VerificationGroup.Update.class})
    private Long userId;

    /**
     * 文章标题
     */
    @TableField("title")
    @NotNull(message = "文章标题不能为空",groups = VerificationGroup.Save.class)
    @Length(min = 1,max = 200,message ="文章标题字数不符合",
            groups = {VerificationGroup.Save.class,VerificationGroup.Update.class})
    private String title;

    /**
     * 分类id
     */
    @TableField("classification_id")
    @NotNull(message = "文章分类不能为空",groups = VerificationGroup.Save.class)
    private Long classificationId;

    /**
     * 文章内容
     */
    @TableField("content")
    @NotNull(message = "文章分类不能为空",groups = VerificationGroup.Save.class)
    @Length(min = 1,max = 200000,message ="文章内容字数不符合",
            groups = {VerificationGroup.Save.class,VerificationGroup.Update.class})
    private String content;

    /**
     * 文章摘要
     */
    @TableField("article_abstract")
    private String articleAbstract;

    /**
     * 是否为草稿
     */
    @TableField("article_is_draft")
    private Boolean articleIsDraft;

    /**
     * 是否私有
     */
    @TableField("article_is_private")
    private Boolean articleIsPrivate;

    @TableField("deleted")
    @TableLogic
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    @JsonIgnore
    private Boolean deleted;

    @TableField(value = "insert_time", fill = FieldFill.INSERT)
    @ApiModelProperty(hidden = true)
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    private LocalDateTime insertTime;

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(hidden = true)
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    private LocalDateTime updateTime;

    public String getArticleAbstract() {
        return articleAbstract;
    }

    public void setArticleAbstract(String articleAbstract) {
        this.articleAbstract = articleAbstract;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Long getClassificationId() {
        return classificationId;
    }

    public void setClassificationId(Long classificationId) {
        this.classificationId = classificationId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }


    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public LocalDateTime getInsertTime() {
        return insertTime;
    }

    public void setInsertTime(LocalDateTime insertTime) {
        this.insertTime = insertTime;
    }


    public Boolean getArticleIsDraft() {
        return articleIsDraft;
    }

    public void setArticleIsDraft(Boolean articleIsDraft) {
        this.articleIsDraft = articleIsDraft;
    }

    public Boolean getArticleIsPrivate() {
        return articleIsPrivate;
    }

    public void setArticleIsPrivate(Boolean articleIsPrivate) {
        this.articleIsPrivate = articleIsPrivate;
    }

    @Override
    public String toString() {
        return "Article{" +
                "id=" + id +
                ", userId=" + userId +
                ", title='" + title + '\'' +
                ", classificationId=" + classificationId +
                ", content='" + content + '\'' +
                ", articleAbstract='" + articleAbstract + '\'' +
                ", articleIsDraft=" + articleIsDraft +
                ", articleIsPrivate=" + articleIsPrivate +
                ", deleted=" + deleted +
                ", insertTime=" + insertTime +
                ", updateTime=" + updateTime +
                '}';
    }
}
